#include <iostream>
#include <cmath>
#include <vector>
using namespace std;

int main(int argc,char *argv [ ]){
    //第一小问
    int beta = 2, p = 3, L = -1, U = 1;
    double UFL = pow(beta, L), OFL = pow(beta, U) * (beta - pow(beta, 1 - p));
    cout << "UFL = " << UFL << " OFL = " << OFL << endl;

    //第二小问
    vector<double> num;
    int i, j;
    num.push_back(0);
    for (i = L; i <= U; i++)
    {
        for (j = 0; j < pow(beta, p - 1); j++)
        {
            num.push_back((1 + j * pow(beta, 1 - p)) * pow(beta, i));
            num.push_back(-(1 + j * pow(beta, 1 - p)) * pow(beta, i));
        }
    }
    cout << "F中的所有数字为： " << endl;
    for (i = 0; i < num.size(); i++)
    {
        cout << num[i] << " ";
        if (i % 5 == 4)
            cout << endl;
    }
    cout << "数字个数为：" << num.size() << endl;

    //第四小问
    vector<double> subnum;
    for (j = 1; j < pow(beta, p - 1); j++)
    {
        subnum.push_back((j * pow(beta, 1 - p)) * pow(beta, L));
        subnum.push_back(-(j * pow(beta, 1 - p)) * pow(beta, L));
    }
    cout << "F中的所有次正规数为：" << endl;
    for (i = 0; i < subnum.size(); i++)
    {
        cout << subnum[i] << " ";
    }
    cout << endl;
    cout << "次正规数的个数为：" << subnum.size() << endl;

    return 0;
}
